import 'dart:convert' show json;

import 'package:flutter_common_app/data/protection.dart';

class DragonBallData {
  DragonBallData({
    this.id,
    this.name,
    this.iconUrl,
    this.url,
    this.skinSupport,
    this.homepageMode,
  });

  factory DragonBallData.fromJson(Map<String, dynamic> jsonRes) =>
      jsonRes == null
          ? null
          : DragonBallData(
              id: asT<int>(jsonRes['id']),
              name: asT<String>(jsonRes['name']),
              iconUrl: asT<String>(jsonRes['iconUrl']),
              url: asT<String>(jsonRes['url']),
              skinSupport: asT<bool>(jsonRes['skinSupport']),
              homepageMode: asT<String>(jsonRes['homepageMode']),
            );

  int id;
  String name;
  String iconUrl;
  String url;
  bool skinSupport;
  String homepageMode;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'id': id,
        'name': name,
        'iconUrl': iconUrl,
        'url': url,
        'skinSupport': skinSupport,
        'homepageMode': homepageMode,
      };

  @override
  String toString() {
    return json.encode(this);
  }

  static List<DragonBallData> fromJsonList(List list){
    return list.map((item) => DragonBallData.fromJson(item)).toList();
  }
}
